package com.sx.pipeline.ui.login.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.sx.pipeline.ui.login.frag.AccountLoginFragment
import com.sx.pipeline.ui.login.frag.VerifyCodeLoginFragment

/**
 * @Author: YY
 * @Date: 2022/4/6
 * @Description: 登录页面 - 适配器
 */
class LoginPageAdapter(
    private val tabs: List<String>,
    fm: FragmentManager, lifecycle: Lifecycle
) : FragmentStateAdapter(fm, lifecycle) {

    override fun getItemCount(): Int {
        return tabs.size
    }

    override fun createFragment(position: Int): Fragment {
        return when(position) {
            0 -> {
                VerifyCodeLoginFragment.newInstance(position)
            }
            else -> {
                AccountLoginFragment.newInstance(position)
            }
        }
    }
}